<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * motto: 现在的努力是为了小时候吹过的牛逼！
 * Date: 2020/1/7
 * Time: 10:22
 */
namespace app\common\business;
use app\common\model\mysql\Demo as DemoModel;
class Demo {

    /**
     * business层通过getDemoDataByCategoryId来获取数据
     * @param $categoryId
     * @param int $limit
     * @return array
     */
    public function getDemoDataByCategoryId($categoryId, $limit=10){

        $model = new DemoModel();
        $result = $model->getDemoDataByCategoryId($categoryId,$limit);
        if (empty($result)){
            return [];
        }
        $category = config("category");
        foreach ($result as $key=>$value){
            $result[$key]['categoryName'] = $category[$value["category_id"]]??"其他";
        }

        return $result;

    }
}